"""
@title(TenX腾晓2024年12月考核答题文件)
@warning(请勿修改参数和返回值)
@warning(请认真填写__init__中的数据)
@author(1323230180)
@license(CC BY-SA 4.0 License)
"""
import os
from copy import deepcopy


class TenXClass:
    def __init__(self):
        # 获取当前文件名并截取文件名的学号-姓名
        file_name = os.path.basename(__file__).split('.')[0].split("-")
        self.id = file_name[0]  # 学号
        self.name = file_name[1]  # 姓名

    @staticmethod
    def question1(*args) -> list[str]:
        binary_tree = deepcopy(args[0])  # 传入的地牢结构（二叉树），详细请看BinaryTree.py

        temp = 0

        def find_deep_0(root, path):
            global temp
            arr = path[:]

            if root:
                arr.append(root.value)
                temp = root
                find_deep_0(root.left, arr)
                find_deep_0(root.right, arr)
            else:
                if temp.value == '0' and temp.left == None and temp.right == None and "".join(arr) not in answer:
                    answer.append("".join(arr))

        answer = []
        find_deep_0(binary_tree.root, [])
        return answer

    @staticmethod
    def question2(*args) -> str:
        matrix = deepcopy(args[0])  # 传入的河流结构（矩阵）

        def find_max(arr):
            answer = ""
            for arr1 in arr:
                answer = answer + str(max(arr1))
            return answer

        return find_max(matrix)

    @staticmethod
    def question3(*args) -> int:
        # mod = 99999999
        # #答案 = 不讨厌的 — 虽然不讨厌但是不含9的 
        # answer = (6*(pow(7,999)) - (5*pow(6,999))) % mod

        return 52808343

    @staticmethod
    def question4(*args) -> int:
        n = deepcopy(args[0])  # 用于搭建金字塔的球个数

        def max_plie(num):
            plie_num = 1
            plie = 0
            while plie_num <= num:
                plie += 1
                num -= plie_num
                plie_num += plie + 1

            return plie

        return max_plie(n)

    @staticmethod
    def question5(*args) -> str:
        balls = deepcopy(args[0])  # 五行空间球的初始值

        def update1(n):
            #搜索上一个
            dic = {1: 5, 2: 1, 3: 2, 4: 3, 5: 4}
            return dic[n]

        def update2(n):
            #搜索上两个
            dic = {1: 4, 2: 5, 3: 1, 4: 2, 5: 3}
            return dic[n]

        def update3(n):
            #搜索下一个
            dic = {1: 2, 2: 3, 3: 4, 4: 5, 5: 1}
            return dic[n]

        def overlay(arr):
            num = 1
            while min(arr) < 10000:
                arr[num - 1] = arr[update1(num) - 1] + arr[update2(num) - 1]
                num = update3(num)

            return arr

        return overlay(balls)
